package thread2;

import java.util.Stack;


public class Consumer extends Thread{
	Fifo f;
	String s;
	int n;
	
	
	public Consumer(Fifo f0, String s0, int n0){
		f = f0; s = s0; n = n0;
	}
	
	public void run(){
		try{
			
			while(true){
				Thread.sleep(n);
				
				String readstring = f.get();
				
				String tm = "";
				long time = System.currentTimeMillis();
				Stack<Integer> digits = new Stack<Integer>();
	/*****  stack feltoltese a digitekkel******/
				for (int j = 0; j < 5; j++){
					digits.push((int)(time % 10));
					time = time / 10;
				}
	/**************** kiiratas ****************/
				for (int k = 0; k < 5; k++){
					tm = tm + digits.pop();
					
				}
				
				System.out.println(s + " " + "consumed: " + "   " + readstring + " " + "time consumed: " + tm);
				
				
			}
			
		}catch (Exception e){
			
		}
	}
}

